package com.china08.yxyapi.repository.mg;

import java.util.Date;
import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.cache.annotations.YxCacheConfig;
import com.china08.yxyapi.entity.mg.platform.YxyHomeNews;

@Cacheable
@YxCacheConfig

public interface YxyHomeNewsRepository extends MongoRepository<YxyHomeNews, String> {
    YxyHomeNews findById(String id);

    long countBySchoolId(String schoolId);

    YxyHomeNews findTop1BySchoolIdAndStatusOrderByCreatedDateDesc(String schoolId, Integer status);

    List<YxyHomeNews> findTop6ByEdbIdAndStatusOrderByCreatedDateDesc(String schoolId, int status);

    YxyHomeNews findByIdAndEdbIdAndStatus(String id, String schoolId, int status);

    YxyHomeNews findTop1ByCreatedDateGreaterThanOrderByCreatedDateAsc(Date currentDate);

    YxyHomeNews findTop1ByCreatedDateLessThanOrderByCreatedDateDesc(Date currentDate);

    YxyHomeNews findTop1ByEdbIdAndCreatedDateGreaterThanOrderByCreatedDateAsc(String schoolId, Date currentDate);

    YxyHomeNews findTop1ByEdbIdAndCreatedDateLessThanOrderByCreatedDateDesc(String schoolId, Date currentDate);

    YxyHomeNews findTop1ByEdbIdAndStatusAndCreatedDateGreaterThanOrderByCreatedDateAsc(String schoolId, int status, Date currentDate);

    YxyHomeNews findTop1ByEdbIdAndStatusAndCreatedDateLessThanOrderByCreatedDateDesc(String schoolId, int status, Date currentDate);

    Page<YxyHomeNews> findByEdbIdAndStatus(String schoolId, int i, Pageable pageable);

    List<YxyHomeNews> findTop8ByEdbIdAndStatusOrderByPvDesc(String schoolId, int i);
}
